#include "SystemMonitor.h"

#include <stdint.h>
#include <stdio.h>

#include "los_tick.h"
#include "los_memory.h"
// #include "los_cpup.h"

void get_los_status()
{
    uint64_t sys_cycle = 0;
    uint32_t cycle_per_tick = 0;
    uint32_t one_tick_to_ms = 0;
    uint32_t cpu_usage = 0;

    LOS_MEM_POOL_STATUS memPool_status;

    sys_cycle = LOS_SysCycleGet();
    cycle_per_tick = LOS_CyclePerTickGet();
    one_tick_to_ms = LOS_Tick2MS(1);
    
    printf("[los_status] sysCycle=%llu, cyclePerTick=%u, oneTickToMs=%u\n", sys_cycle, cycle_per_tick, one_tick_to_ms);

    cpu_usage = LOS_HistorySysCpuUsage(1);
    printf("[los_status] cpuUsage=%d\n", cpu_usage);

    

    LOS_MemInfoGet(OS_SYS_MEM_ADDR, &memPool_status);
    printf("[los_status] tused: %d, tfree: %d\n", memPool_status.totalUsedSize, memPool_status.totalFreeSize);

}

void get_one_second_tick()
{
    uint64_t tick_count_start = 0;
    uint64_t tick_count_end = 0;

    //1s前 获取 tick count
    tick_count_start = LOS_TickCountGet();

    LOS_Msleep(1000);   //延时1s

    //1s后 获取 tick count
    tick_count_end = LOS_TickCountGet();


    printf("[los_status] 1000ms tick count= %llu\n", tick_count_end - tick_count_start);
}
